<template>
  <div>
    <van-form @submit="onSubmit">
      <van-field
        :rules="[{ required: true, message: '请填写用户名' }]"
        label="用户名"
        name="username"
        placeholder="用户名"
        v-model="username"
      />
      <van-field
        :rules="[{ required: true, message: '请填写密码' }]"
        label="密码"
        name="password"
        placeholder="密码"
        type="password"
        v-model="password"
      />
      <div style="margin: 16px;">
        <van-button block native-type="submit" round style="border-radius: 0%;" type="info">提交</van-button>
      </div>
      <div>
        <router-link
          style="list-style: none; color: #069; font-size: 14px;position: fixed;right: 15px;"
          to="/"
        >已有账号？去登陆</router-link>
      </div>
    </van-form>
  </div>
</template>
 <script>
import request from '@/utils/request';
export default {
  data () {
    return {
      username: '',
      password: '',
    };
  },
  methods: {
    async onSubmit () {
      const res = await request.post('/user/register', {
        username: this.username,
        password: this.password
      });

      console.log(res);
    },
  },
};
 </script>
 <style lang='less'  scoped>
</style>